import request from '@/utils/axios'

export interface ArticleType {
  id: number
  categoryId: number
  title: string
  author: string
  picUrl: string
  introduction: string
  browseCount: string
  sort: number
  status: number
  spuId: number
  recommendHot: boolean
  recommendBanner: boolean
  content: string
}

/**
 * 营销文章接口
 */
export const ArticleApi = {
  // 创建营销文章
  create: async (data: ArticleType) => {
    return await request.post({
      url: '/promotion/article/create',
      data,
      is_mock: true
    })
  },
  // 更新营销文章
  update: async (data: ArticleType) => {
    return await request.post({
      url: '/promotion/article/update',
      data,
      is_mock: true
    })
  },
  // 删除营销文章
  delete: async (id: number) => {
    return await request.delete({ url: `/promotion/article/delete?id=${id}`, is_mock: true })
  },
  // 获取文章详情
  detail: async (id: number) => {
    return await request.get({
      url: '/promotion/article/get?id=' + id,
      is_mock: true
    })
  },
  // 查询分页列表
  page: async params => {
    return await request.get({
      url: '/promotion/article/page',
      params,
      is_mock: true
    })
  }
}
